USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0002_NOTARIO]    Script Date: 11/24/2011 14:34:42 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WASP_M0002_NOTARIO]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WASP_M0002_NOTARIO]
GO

USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0002_NOTARIO]    Script Date: 11/24/2011 14:34:42 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[WASP_M0002_NOTARIO]
AS
BEGIN
    SELECT	hsucur AS suc
			,hcta AS cta
			,hoper AS ope
			,hcimp1 AS notario
    INTO	notaria
    FROM	fsh016
    WHERE	hrubro = 2124020100
    
    /*
    select 
	    txtsuc as suc,
	    txtcta as cta,
	    txtope as ope,
	    sum(convert(numeric, txtord)) as notario
    into 
	notaria
    from 
	    fsx016 (NOLOCK)
    where 
	    txcod=110
    group by txtsuc,
	    txtcta,
	    txtope,
	    txtsbo
    union 
     
    SELECT Z07391SU1 as suc , Z07391CT1 as cta ,   Z07391OP1 as ope,  X054030.XllAoCoImp as notario
    FROM Z07391 ,
               X054023 as X054023,
               X054030 as X054030
    WHERE 
    Z07391PRO <> 0 AND Z07391INS <> 0 AND Z07391WOR = 0 AND
    X054023.XllPgcod = Z07391PG1 AND
    X054023.XllAomod = Z07391MO1 AND
    X054023.XllAosuc = Z07391SU1 AND
    X054023.XllAomda = Z07391MA1 AND
    X054023.XllAopap = Z07391PA1 AND
    X054023.XllAocta = Z07391CT1 AND
    X054023.XllAooper = Z07391OP1 AND
    X054023.XllAosbop = Z07391SB1 AND
    X054023.XllAotop = Z07391TP1 AND
    X054023.XllPgcod = X054030.XllPgcod AND
    X054023.XllAomod = X054030.XllAomod AND
    X054023.XllAosuc = X054030.XllAosuc AND
    X054023.XllAomda = X054030.XllAomda AND
    X054023.XllAopap = X054030.XllAopap AND
    X054023.XllAocta = X054030.XllAocta AND
    X054023.XllAooper =X054030.XllAooper AND
    X054023.XllAosbop =X054030.XllAosbop AND
    X054023.XllAotop = X054030.XllAotop */
END

GO


